namespace SimpleWebServices.Data
{
    using System;
    using Xunit;

    public sealed class SqlClientRepositoryFacts
    {
        [Fact]
        public void typedef()
        {
            Assert.True(new ObjectExpectations<SqlClientRepository>()
                .DerivesFrom<object>()
                .IsConcreteClass()
                .IsSealed()
                .HasDefaultConstructor()
                .Implements<IRepository>()
                .Result);
        }

        [Fact]
        public void repository()
        {
            Assert.True(new RepositoryExpectations<SqlClientRepository>().Result);
        }

        [Fact]
        public void ctor()
        {
            Assert.NotNull(new SqlClientRepository());
        }

        [Fact]
        public void ctor_string()
        {
            Assert.NotNull(new SqlClientRepository("Data Source=.;Initial Catalog=Repository;Integrated Security=True"));
        }

        [Fact]
        public void ctor_stringEmpty()
        {
            Assert.Throws<ArgumentOutOfRangeException>(() => new SqlClientRepository(string.Empty));
        }

        [Fact]
        public void ctor_stringNull()
        {
            Assert.Throws<ArgumentNullException>(() => new SqlClientRepository(null as string));
        }

        [Fact]
        public void prop_ConnectionString()
        {
            Assert.True(new PropertyExpectations(typeof(SqlClientRepository).GetProperty("ConnectionString"))
                .TypeIs<string>()
                .DefaultValueIsNotNull()
                .ArgumentNullException()
                .ArgumentOutOfRangeException(string.Empty)
                .Set("Data Source=.;Initial Catalog=Repository;Integrated Security=True")
                .Result);
        }
    }
}